package limeirafol.gui.venda;

import limeirafol.gui.Cadastro.*;
import java.awt.event.KeyEvent;
import java.util.List;
import javax.swing.SwingConstants;
import org.openide.util.Exceptions;
import lbframework.bean.internalFrame.LBInternalFrame;
import lbframework.bean.mdiFrame.LBMdiFrame;
import lbframework.bean.table.LBColumnTable;
import lbframework.classe.Util;
import lbframework.remote.ItemComboVO;
import limeirafol.Global;
import limeirafol.bean.BeanVenda;
import limeirafol.gui.MenuGUI;
import limeirafol.remote.venda.OrdemServicoFiltroConsultaVO;
import limeirafol.remote.venda.OrdemServicoVO;

public class OrdemServicoConsultaGUI extends LBInternalFrame {

    private BeanVenda beanPedido = new BeanVenda();
    private List<OrdemServicoVO> vOrdem = null;

    public OrdemServicoConsultaGUI(LBMdiFrame i_mdiFrame) throws Exception {
        super(i_mdiFrame);

        initComponents();
        centralizarForm();
        this.setMaximum(true);

        cboTipoData.addItem(new ItemComboVO(1, "ABERTURA"));
        cboTipoData.addItem(new ItemComboVO(2, "FINALIZACAO"));
        cboTipoData.setId(1);

        cboSituacao.setTabela("situacaoordemservico");
        cboSituacao.carregar();
        cboSituacao.addItem(new ItemComboVO(-1, "TODOS"));
        cboSituacao.setId(-1);

        cboTipoOrdem.setTabela("tipoordemservico");
        cboTipoOrdem.carregar();
        cboTipoOrdem.addItem(new ItemComboVO(-1, "TODOS"));
        cboTipoOrdem.setId(-1);

        cnsCliente.setTabela("cliente");
        cnsCliente.setCampoDescricao("nome");

        txtDataInicio.setConsultaData(Global.class.getMethod("getDataProcessamento"));
        txtDataTermino.setConsultaData(Global.class.getMethod("getDataProcessamento"));

    }

    @Override
    public void consultar() throws Exception {
        Util.validarCampoTela(this.getCampoObrigatorio());

        if (!txtDataInicio.getClipText().isEmpty() && !txtDataTermino.getClipText().isEmpty()) {
            Util.validarIntervaloData(txtDataInicio, txtDataTermino);
        }

        OrdemServicoFiltroConsultaVO oFiltro = new OrdemServicoFiltroConsultaVO();

        oFiltro.tipoData = cboTipoData.getId();
        oFiltro.dataInicio = txtDataInicio.getClipText().equals("") ? "" : txtDataInicio.getText();
        oFiltro.dataTermino = txtDataTermino.getClipText().equals("") ? "" : txtDataTermino.getText();
        oFiltro.idCliente = cnsCliente.getId();
        oFiltro.idSituacao = cboSituacao.getId();
        oFiltro.numeroOrdemServico = txtNumeroOrdemServico.getInt();
        oFiltro.idTipoOrdem = cboTipoOrdem.getId();

        vOrdem = beanPedido.consultarOrdemServico(oFiltro);

        exibirConsulta();
    }

    @Override
    public void incluir() throws Exception {
        OrdemServicoCadastroGUI form = new OrdemServicoCadastroGUI(mdiFrame);

        form.incluir();
        form.setVisible(true);
    }

    public void carregarOrdemServico() throws Exception {
//        if (tblConsulta.getLinhaSelecionada() == -1) {
//            throw new LBException(Util.MSG_NENHUM_ITEM_SELECIONADO);
//        }
//        PedidoVO oPedido = vPedido.get(tblConsulta.getLinhaSelecionada());
//
//        if (consultaCampo == null) {
//            PedidoCadastroGUI form = new PedidoCadastroGUI(mdiFrame);
//
//            form.carregarPedido(oPedido.numeroPedido);
//            form.setVisible(true);
//
//        } else {
//            this.setVisible(false);
//
//            consultaCampo.setParentSelected(true);
//            consultaCampo.setId((int) oPedido.numeroPedido);
//            consultaCampo.consultar(true);
//            consultaCampo.transferFocus();
//        }
    }

    private void exibirConsulta() throws Exception {
        LBColumnTable[] colunas = new LBColumnTable[]{
            new LBColumnTable("Nro. O.S.", 70, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Cod. Cliente", 80, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Cliente", 200, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Tipo Ordem", 90, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Data Abertura", 110, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Data Finalizacao", 110, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Situacao", 90, true, SwingConstants.LEFT, false, null),};

        Object[][] dados = new Object[vOrdem.size()][colunas.length];

        int i = 0;

        for (OrdemServicoVO oOrdem : vOrdem) {

            dados[i][0] = Util.formatNumber(oOrdem.id, 6);
            dados[i][1] = Util.formatNumber(oOrdem.idCliente, 6);
            dados[i][2] = oOrdem.cliente;
            dados[i][3] = oOrdem.tipoOrdem;
            dados[i][4] = oOrdem.dataHoraAbertura;
            dados[i][5] = oOrdem.dataHoraFinalizacao;
            dados[i][6] = oOrdem.situacao;

            i++;
        }

        tblConsulta.setModel(dados, colunas);

        tblConsulta.requestFocus();
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        vRPanel1 = new lbframework.bean.panel.LBPanel();
        vRLabel2 = new lbframework.bean.label.LBLabel();
        cboSituacao = new lbframework.bean.comboBox.LBComboBox();
        vRLabel3 = new lbframework.bean.label.LBLabel();
        txtNumeroOrdemServico = new lbframework.bean.textField.LBTextField();
        cnsCliente = new lbframework.bean.consultaCampo.LBConsultaCampo();
        vRLabel4 = new lbframework.bean.label.LBLabel();
        lBLabel1 = new lbframework.bean.label.LBLabel();
        txtDataInicio = new lbframework.bean.calendar.LBCalendar();
        lBLabel2 = new lbframework.bean.label.LBLabel();
        txtDataTermino = new lbframework.bean.calendar.LBCalendar();
        lBLabel3 = new lbframework.bean.label.LBLabel();
        cboTipoData = new lbframework.bean.comboBox.LBComboBox();
        cboTipoOrdem = new lbframework.bean.comboBox.LBComboBox();
        vRLabel5 = new lbframework.bean.label.LBLabel();
        tblConsulta = new lbframework.bean.tableEx.LBTableEx();
        vRPanel2 = new lbframework.bean.panel.LBPanel();
        vRButton1 = new lbframework.bean.button.LBButton();
        vRButton2 = new lbframework.bean.button.LBButton();
        vRToolBarPadrao1 = new lbframework.bean.toolBarPadrao.LBToolBarPadrao(this);

        setTitle("Ordem de Serviço Consulta");

        vRLabel2.setText("Situação");

        vRLabel3.setText("Nro. O.S.");

        txtNumeroOrdemServico.setMascara("Numero");

        cnsCliente.addEventoConsultaCampoListener(new lbframework.bean.consultaCampo.LBEventoConsultaCampoListener() {
            public void abreTelaConsulta(lbframework.bean.consultaCampo.LBEventoConsultaCampo evt) {
                cnsClienteAbreTelaConsulta(evt);
            }
            public void aposConsulta(lbframework.bean.consultaCampo.LBEventoConsultaCampo evt) {
            }
        });

        vRLabel4.setText("Cliente");

        lBLabel1.setText("Periodo");

        txtDataInicio.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtDataInicioFocusLost(evt);
            }
        });

        lBLabel2.setText("a");

        txtDataTermino.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtDataTerminoFocusLost(evt);
            }
        });

        lBLabel3.setText("Data");

        vRLabel5.setText("Tipo Ordem Serviço");

        javax.swing.GroupLayout vRPanel1Layout = new javax.swing.GroupLayout(vRPanel1);
        vRPanel1.setLayout(vRPanel1Layout);
        vRPanel1Layout.setHorizontalGroup(
            vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lBLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboTipoData, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtDataInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lBLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lBLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtDataTermino, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(vRLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNumeroOrdemServico, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cnsCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(vRLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(vRLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboTipoOrdem, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(vRLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(302, Short.MAX_VALUE))
        );
        vRPanel1Layout.setVerticalGroup(
            vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(txtDataTermino, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lBLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cnsCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(vRPanel1Layout.createSequentialGroup()
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(vRLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(vRLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtNumeroOrdemServico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(vRPanel1Layout.createSequentialGroup()
                        .addComponent(lBLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtDataInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(vRPanel1Layout.createSequentialGroup()
                        .addComponent(lBLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboTipoData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(vRPanel1Layout.createSequentialGroup()
                            .addComponent(vRLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(cboTipoOrdem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(vRPanel1Layout.createSequentialGroup()
                            .addComponent(vRLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(cboSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tblConsulta.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblConsultaMouseClicked(evt);
            }
        });
        tblConsulta.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tblConsultaKeyPressed(evt);
            }
        });

        vRButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/sair.png"))); // NOI18N
        vRButton1.setText("Sair");
        vRButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton1ActionPerformed(evt);
            }
        });

        vRButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/consultar.png"))); // NOI18N
        vRButton2.setText("Consultar");
        vRButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout vRPanel2Layout = new javax.swing.GroupLayout(vRPanel2);
        vRPanel2.setLayout(vRPanel2Layout);
        vRPanel2Layout.setHorizontalGroup(
            vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, vRPanel2Layout.createSequentialGroup()
                .addContainerGap(835, Short.MAX_VALUE)
                .addComponent(vRButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(vRButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        vRPanel2Layout.setVerticalGroup(
            vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(vRButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(vRButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        vRToolBarPadrao1.setRollover(true);
        vRToolBarPadrao1.setVisibleConsultar(true);
        vRToolBarPadrao1.setVisibleEditar(true);
        vRToolBarPadrao1.setVisibleImprimir(true);
        vRToolBarPadrao1.setVisibleIncluir(true);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(vRToolBarPadrao1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tblConsulta, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 1037, Short.MAX_VALUE)
                    .addComponent(vRPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(vRPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(vRToolBarPadrao1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addComponent(vRPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(tblConsulta, javax.swing.GroupLayout.DEFAULT_SIZE, 334, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(vRPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void vRButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton1ActionPerformed
        try {
            sair();

        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        }
    }//GEN-LAST:event_vRButton1ActionPerformed

    private void vRButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton2ActionPerformed
        try {
            consultar();
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        }
    }//GEN-LAST:event_vRButton2ActionPerformed

    private void tblConsultaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblConsultaMouseClicked
        try {
            if (evt.getClickCount() == 2) {
                //   carregarPedido();
            }

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }
    }//GEN-LAST:event_tblConsultaMouseClicked

    private void tblConsultaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblConsultaKeyPressed
        try {
            if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                //   carregarPedido();
            }

            if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
                excluir();
            }

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }
    }//GEN-LAST:event_tblConsultaKeyPressed

    private void txtDataInicioFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtDataInicioFocusLost
        try {
            if (!txtDataInicio.getClipText().isEmpty() || !txtDataTermino.getClipText().isEmpty()) {
                txtDataInicio.setObrigatorio(true);
                txtDataTermino.setObrigatorio(true);
            } else {
                txtDataInicio.setObrigatorio(false);
                txtDataTermino.setObrigatorio(false);
            }

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }
    }//GEN-LAST:event_txtDataInicioFocusLost

    private void txtDataTerminoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtDataTerminoFocusLost
        try {
            if (!txtDataInicio.getClipText().isEmpty() || !txtDataTermino.getClipText().isEmpty()) {
                txtDataInicio.setObrigatorio(true);
                txtDataTermino.setObrigatorio(true);
            } else {
                txtDataInicio.setObrigatorio(false);
                txtDataTermino.setObrigatorio(false);
            }

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }
    }//GEN-LAST:event_txtDataTerminoFocusLost

    private void cnsClienteAbreTelaConsulta(lbframework.bean.consultaCampo.LBEventoConsultaCampo evt) {//GEN-FIRST:event_cnsClienteAbreTelaConsulta
        try {
            MenuGUI menu = (MenuGUI) mdiFrame;

            if (menu.formClienteConsulta == null || menu.formClienteConsulta.isClosed()) {
                menu.formClienteConsulta = new ClienteConsultaGUI(mdiFrame);
            }

            menu.formClienteConsulta.setConsultaCampo(cnsCliente);
            menu.formClienteConsulta.setVisible(true);

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }

    }//GEN-LAST:event_cnsClienteAbreTelaConsulta
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private lbframework.bean.comboBox.LBComboBox cboSituacao;
    private lbframework.bean.comboBox.LBComboBox cboTipoData;
    private lbframework.bean.comboBox.LBComboBox cboTipoOrdem;
    private lbframework.bean.consultaCampo.LBConsultaCampo cnsCliente;
    private lbframework.bean.label.LBLabel lBLabel1;
    private lbframework.bean.label.LBLabel lBLabel2;
    private lbframework.bean.label.LBLabel lBLabel3;
    private lbframework.bean.tableEx.LBTableEx tblConsulta;
    private lbframework.bean.calendar.LBCalendar txtDataInicio;
    private lbframework.bean.calendar.LBCalendar txtDataTermino;
    private lbframework.bean.textField.LBTextField txtNumeroOrdemServico;
    private lbframework.bean.button.LBButton vRButton1;
    private lbframework.bean.button.LBButton vRButton2;
    private lbframework.bean.label.LBLabel vRLabel2;
    private lbframework.bean.label.LBLabel vRLabel3;
    private lbframework.bean.label.LBLabel vRLabel4;
    private lbframework.bean.label.LBLabel vRLabel5;
    private lbframework.bean.panel.LBPanel vRPanel1;
    private lbframework.bean.panel.LBPanel vRPanel2;
    private lbframework.bean.toolBarPadrao.LBToolBarPadrao vRToolBarPadrao1;
    // End of variables declaration//GEN-END:variables
}
